package com.yanwq.sayhi.common.tool;

import android.content.Context;
import android.content.SharedPreferences;

import com.yanwq.sayhi.MApplication;

/**
 * Created by yanwq on 2016/1/26.
 */
public class SharedPrefTool {

    public static long getConfig(String key, long defValue) {

        return getSharedPref().getLong(key, defValue);
    }

    public static void putConfig(String key, long defValue) {

        getSharedPref().edit().putLong(key, defValue).apply();
    }

    public static boolean getConfig(String key, boolean defValue) {

        return getSharedPref().getBoolean(key, defValue);
    }

    public static void putConfig(String key, boolean defValue) {

        getSharedPref().edit().putBoolean(key, defValue).apply();
    }

    public static String getConfig(String key, String defValue) {

        return getSharedPref().getString(key, defValue);
    }

    public static void putConfig(String key, String defValue) {

        getSharedPref().edit().putString(key, defValue).apply();
    }

    private static SharedPreferences getSharedPref() {
        return MApplication.getContext().getSharedPreferences("config", Context.MODE_PRIVATE);
    }

}
